#include<bits/stdc++.h>
using namespace std;
const int N = 185;
struct tlb{
	string n;
	int m , d;
}a[N];
bool cmp(tlb a , tlb b){
	if(a.m != b.m){
		return a.m < b.m;
	}
	if(a.d != b.d){
		return a.d < b.d;
	}
	if(a.n.length() != b.n.length()){
		return a.n.length() < b.n.length();
	}
	return a.n < b.n;
}
int main(){
	freopen("birthday.in", "r", stdin);
	freopen("birthday.out", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i].n >> a[i].m >> a[i].d;
	}
	sort(a + 1 , a + n + 1 , cmp);
	int i = 1 , f = 0;
	while(i <= n){
		int j;
		for(j = i + 1 ; j <= n ; j++){
			if(a[i].m != a[j].m || a[i].d != a[j].d){
				break;
			}
		}
		if(i == j - 1){
			i = j;
			continue;
		}
		cout << a[i].m << " " << a[i].d << " ";
		for(int k = i ; k <= j - 1 ; k++){
				cout << a[k].n << " ";
				f = 1;
		}
		cout << endl;
		i = j;
	}
	if(f == 0){
		cout << "None" << endl; 
	}
	return 0;
}